/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Feb 14, 2012  3:29:48 PM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : apps.promis.in.common
 * File Name : CompanyAction.java
 * TODO
 */
package apps.promis.in.common;

import java.util.List;

import org.apache.log4j.Logger;

import promis.utility.Utilitys;
import apps.sessionFactory;
import jpa.entitys.promis.common.Company;
import jpa.service.promis.common.CompanyServices;

/**
 * 
 * @author Chatree Siangklom of Administrator
 * Date =Nov 13, 2013 : 2:30:07 PM 
 * CreateBy=Chatree Siangklom
 * 
 * CompanyAction
 * TODO
 */
public class CompanyAction {
	
	private static final Logger log = Logger.getLogger(CompanyAction.class);
	
	public Company FindByCode(String company_code) throws Exception {
		
		CompanyServices companySrv = new CompanyServices(sessionFactory.CreateEmPromis());		
		return companySrv.findById(company_code);
	}
	
	public boolean ExistingChecked(String company_code) throws Exception {
		return FindByCode(company_code) != null ? true : false;		
	}
	
	public Company FindBySapCompany(String sapCompanyCode) throws Exception {
		CompanyServices companySrv = new CompanyServices(sessionFactory.CreateEmPromis());
		return companySrv.findBySapCompany(sapCompanyCode);
	}
	

//	/**
//	 * @param args
//	 */
//	public static void main(String args[]){
//		
//		CompanyAction companyAct = new CompanyAction();
//		try {		
//			
//			Company company = companyAct.FindByCode("SP");
//			if(company != null)
//			{
//				log.info("getCompany : " + company.getCompany());
//				log.info("getDescription : " + company.getDescription());	
//				log.info("getCompanyAddress : " + company.getCompanyAddress());	
//			}				
//			
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		
//	}


}
